#include "host/hcd.h"
#include "portable/ehci/hcd_ehci.h"
#include "agrv2k.h"

// Initialize controller to host mode
bool hcd_init(uint8_t rhport)
{
  SYS_EnableAHBClock(AHB_MASK_USB0);
  USB_InitHost();
  USB_OtgAutoReset();

  return hcd_ehci_init(rhport);
}

void hcd_int_enable (uint8_t rhport)
{
  INT_EnableIRQ(USB0_IRQn, PLIC_MAX_PRIORITY);
}

void hcd_int_disable(uint8_t rhport)
{
  INT_DisableIRQ(USB0_IRQn);
}

uint32_t hcd_ehci_register_addr(uint8_t rhport)
{
  return (uint32_t)&USB->USBCMD;
}
